package utils

/*
Option
大数运算整合
*/
func Option(s1 string, s2 string, opt int8, bit int) (res string) {
	switch opt {
	case PLUS:
		if isFloat(s1) {
			if isFloat(s2) {
				return bigFloatPlus(s1, s2)
			} else {
				return bigFloatPlus(s1, s2+makeFloatSuffix)
			}
		} else {
			if isFloat(s2) {
				return bigFloatPlus(s1+makeFloatSuffix, s2)
			} else {
				return bigIntegerPlus(s1, s2)
			}
		}
	case SUB:
		if isFloat(s1) {
			if isFloat(s2) {
				return bigFloatSub(s1, s2)
			} else {
				return bigFloatSub(s1, s2+makeFloatSuffix)
			}
		} else {
			if isFloat(s2) {
				return bigFloatSub(s1+makeFloatSuffix, s2)
			} else {
				return bigIntegerSub(s1, s2)
			}
		}
	case MULTIPLY:
		if isFloat(s1) {
			if isFloat(s2) {
				return bigFloatMultiply(s1, s2)
			} else {
				return bigFloatMultiply(s1, s2+makeFloatSuffix)
			}
		} else {
			if isFloat(s2) {
				return bigFloatMultiply(s1+makeFloatSuffix, s2)
			} else {
				return bigIntegerMultiply(s1, s2)
			}
		}
	case DIVIDE:
		if isFloat(s1) {
			if isFloat(s2) {
				return bigFloatDivide(s1, s2, bit)
			} else {
				return bigFloatDivide(s1, s2+makeFloatSuffix, bit)
			}
		} else {
			if isFloat(s2) {
				return bigFloatDivide(s1+makeFloatSuffix, s2, bit)
			} else {
				multiple, _ := bigIntegerDivide(s1, s2)
				return multiple
			}
		}
	case REMINDER:
		if isFloat(s1) {
			if isFloat(s2) {
				return bigFloatReminder(s1, s2, bit)
			} else {
				return bigFloatReminder(s1, s2+makeFloatSuffix, bit)
			}
		} else {
			if isFloat(s2) {
				return bigFloatReminder(s1+makeFloatSuffix, s2, bit)
			} else {
				_, reminder := bigIntegerDivide(s1, s2)
				return reminder
			}
		}
	default:
		panic("unsupported option")
	}
}
